<!--/* DiagnosticResults -->
<!--
TABLE 1: Observations
Code: Observation.code.text || Observation.code.coding[x].display (separated by <br />)
Result: Observation.valueQuantity || Observation.valueDateTime || Observation.valueCodeableConcept.text || Observation.valueCodeableConcept.coding[x].display (separated by <br />) || Observation.valueString
Unit: Observation.valueQuantity.unit
Interpretation: Observation.interpretation[0].text || Observation.interpretation[0].coding[x].display (separated by <br />)
Reference Range: Observation.referenceRange[x]{ text || low.value && “-“ && high.value} (concatenate with comma, e.g. x, y, z)
Comments: Observation.note[x].text (separated by <br />)
Date: Observation.effectiveDateTime || Observation.effectivePeriod.start

TABLE 2: Diagnostic Reports
Code: DiagnosticReport.code.text || DiagnosticReport.code.coding[x].display (separated by <br />)
Date: DiagnosticReport.effectiveDateTime || DiagnosticReport.effectivePeriod.start
*/-->
<div xmlns:th="http://www.thymeleaf.org">
	<th:block th:if="${narrativeUtil.bundleHasEntriesWithResourceType(resource, 'Observation')}">
		<h5>Diagnostic Results: Observations</h5>
		<table class="hapiPropertyTable">
			<thead>
			<tr>
				<th>Code</th>
				<th>Result</th>
				<th>Unit</th>
				<th>Interpretation</th>
				<th>Reference Range</th>
				<th>Comments</th>
				<th>Date</th>
			</tr>
			</thead>
			<tbody>
			<th:block th:each="entry : ${resource.entry}" th:object="${entry.getResource()}">
				<th:block th:if='*{getResourceType().name() == "Observation"}'>
					<th:block th:unless='*{getResourceType().name() == "Composition"}'>
						<th:block
							th:with="extension=${entry.getResource().getExtensionByUrl('http://hl7.org/fhir/StructureDefinition/narrativeLink').getValue().getValue()}">
							<tr th:id="${#strings.arraySplit(extension, '#')[1]}">
								<td th:insert="~{IpsUtilityFragments :: codeableConcept (cc=*{getCode()},attr='display')}">Code
								</td>
								<td th:insert="~{IpsUtilityFragments :: renderValue (value=*{getValue()})}">Result</td>
								<td th:insert="~{IpsUtilityFragments :: renderValueUnit (value=*{getValue()})}">Unit</td>
								<td
									th:insert="~{IpsUtilityFragments :: firstFromCodeableConceptList (list=*{getInterpretation()})}">
									Interpretation
								</td>
								<td th:insert="~{IpsUtilityFragments :: concatReferenceRange (list=*{getReferenceRange()})}">
									Reference
									Range
								</td>
								<td th:insert="~{IpsUtilityFragments :: concat (list=*{getNote()},attr='text')}">Comments</td>
								<td th:insert="~{IpsUtilityFragments :: renderEffective (effective=*{getEffective()})}">Date</td>
							</tr>
						</th:block>
					</th:block>
				</th:block>
			</th:block>
			</tbody>
		</table>
	</th:block>

	<th:block th:if="${narrativeUtil.bundleHasEntriesWithResourceType(resource, 'DiagnosticReport')}">
		<h5>Diagnostic Results: Diagnostic Reports</h5>
		<table class="hapiPropertyTable">
			<thead>
			<tr>
				<th>Code</th>
				<th>Date</th>
			</tr>
			</thead>
			<tbody>
			<th:block th:each="entry : ${resource.entry}" th:object="${entry.getResource()}">
				<th:block th:if='*{getResourceType().name() == "DiagnosticReport"}'>
					<th:block th:unless='*{getResourceType().name() == "Composition"}'>
						<th:block
							th:with="extension=${entry.getResource().getExtensionByUrl('http://hl7.org/fhir/StructureDefinition/narrativeLink').getValue().getValue()}">
							<tr th:id="${#strings.arraySplit(extension, '#')[1]}">
								<td th:insert="~{IpsUtilityFragments :: codeableConcept (cc=*{getCode()},attr='display')}">Device
								</td>
								<td th:insert="~{IpsUtilityFragments :: renderEffective (effective=*{getEffective()})}">Date</td>
							</tr>
						</th:block>
					</th:block>
				</th:block>
			</th:block>
			</tbody>
		</table>
	</th:block>
</div>
